public class MyDate {
    public int year;
    //year = 100;只能直接写，不能另起一行
    public int month;
    public int day;

    public MyDate(){
        System.out.println("不带参数的构造方法!");
    }
    public MyDate(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("带有3个参数的构造方法!");
    }
    public void setDay(int y,int m,int d){
        year = y;
        month = m;
        day = d;
    }

    public void printDay(){
        System.out.println(year + "-" + month + "-" + day);
    }

    public static void main(String[] args) {
        MyDate myDate = new MyDate();
        myDate.setDay(2022,2,20);
        myDate.printDay();

        MyDate myDate2 = new MyDate();
        myDate2.setDay(2022,2,22);
        myDate2.printDay();

    }
}

